package com.example.ex3;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class RateChangeActivity extends AppCompatActivity {
    private static final String TAG = "Ratechange";
    private String cname;
    private float cval;
    TextView change;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rate_change);

        Intent intent = getIntent();
        cname = intent.getStringExtra("cname");
        Log.i(TAG,"ratechange:first"+cname);
        cval = Float.parseFloat(intent.getStringExtra("number"));

        Log.i(TAG,"ratechange:first"+cval);
        change = findViewById(R.id.change);
        change.setText(cname);
    }

    public void get(View btn){
        EditText input = findViewById(R.id.number);
        String s = input.getText().toString();
        if(s.length()==0){
            return;
        }
        Log.i(TAG,"ratechange:second");
        float inp = Float.parseFloat(s);
        float r = 0.0f;
        r=inp * (100f/cval);
        change.setText(cname+":"+String.valueOf(r));
    }
}